# 设置目标系统名称
set(CMAKE_SYSTEM_NAME Linux)

# 设置目标架构
set(CMAKE_SYSTEM_PROCESSOR arm)

# 指定交叉编译器前缀（不需要全路径，因为已配置环境变量）
set(TOOLCHAIN_PREFIX arm-htnice-linux-gnueabihf-)

# 设置C和C++编译器
set(CMAKE_C_COMPILER ${TOOLCHAIN_PREFIX}gcc)
set(CMAKE_CXX_COMPILER ${TOOLCHAIN_PREFIX}g++)

# 设置链接器和其他工具
set(CMAKE_LINKER ${TOOLCHAIN_PREFIX}ld CACHE PATH "Linker" FORCE)
set(CMAKE_AR ${TOOLCHAIN_PREFIX}ar CACHE PATH "Archiver" FORCE)
set(CMAKE_NM ${TOOLCHAIN_PREFIX}nm CACHE PATH "NM" FORCE)
set(CMAKE_OBJDUMP ${TOOLCHAIN_PREFIX}objdump CACHE PATH "Objdump" FORCE)
set(CMAKE_RANLIB ${TOOLCHAIN_PREFIX}ranlib CACHE PATH "Ranlib" FORCE)

# 设置目标根目录（根据您的实际sysroot路径修改）
# set(CMAKE_FIND_ROOT_PATH /path/to/your/sysroot)

# 修改查找行为
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)

# 设置编译标志 - 针对32位ARM架构
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -march=armv7-a -mfloat-abi=hard -mfpu=neon-vfpv4" CACHE STRING "Compiler flags" FORCE)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=armv7-a -mfloat-abi=hard -mfpu=neon-vfpv4" CACHE STRING "Compiler flags" FORCE)